using System;
using System.Collections;
using System.Text;

namespace Qiang.Topology.Planargraph
{
    /// <summary>
    /// The base class for all graph component classes.
    /// Maintains flags of use in generic graph algorithms.
    /// Provides two flags:
    /// 
    /// marked - typically this is used to indicate a state that persists
    /// for the course of the graph's lifetime.  For instance, it can be
    /// used to indicate that a component has been logically deleted from the graph.
    /// visited - this is used to indicate that a component has been processed
    /// or visited by an single graph algorithm.  For instance, a breadth-first traversal of the
    /// graph might use this to indicate that a node has already been traversed.
    /// The visited flag may be set and cleared many times during the lifetime of a graph.
    /// </summary>
    public class GraphComponent
    {
        /// <summary>
        /// 
        /// </summary>
        protected bool isMarked = false;

        /// <summary>
        /// 
        /// </summary>
        protected bool isVisited = false;

        /// <summary>
        /// 
        /// </summary>
        public GraphComponent() { }

        /// <summary>
        /// Tests if a component has been visited during the course of a graph algorithm.
        /// </summary>
        /// <returns><c>true</c> if the component has been visited.</returns>        
        public virtual bool IsVisited
        {
            get
            {
                return Visited;
            }
        }
       
        /// <summary> 
        /// Gets/Sets the visited flag for this component.
        /// </summary>
        public virtual bool Visited
        {
            get
            {
                return this.isVisited;
            }
            set
            {
                this.isVisited = value;
            }
        }

        /// <summary>
        /// Tests if a component has been marked at some point during the processing
        /// involving this graph.
        /// </summary>
        /// <returns><c>true</c> if the component has been marked.</returns>
        public virtual bool IsMarked
        {
            get
            {
                return Marked;
            }
        }

        /// <summary>
        /// Gets/Sets the marked flag for this component.
        /// </summary>
        /// <param name="isMarked">The desired value of the marked flag.</param>
        public virtual bool Marked
        {
            get
            {
                return this.isMarked;
            }
            set
            {
                this.isMarked = value;
            }
        }
    }
}
